package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC824 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String toGoatLatin(String sentence) {
            Set<Character> vowels = new HashSet<Character>() {{
                add('a');
                add('e');
                add('i');
                add('o');
                add('u');
                add('A');
                add('E');
                add('I');
                add('O');
                add('U');
            }};

            int n = sentence.length();
            int i = 0, cnt = 1;
            StringBuffer ans = new StringBuffer();

            while (i < n) {
                int j = i;
                while (j < n && sentence.charAt(j) != ' ') {
                    ++j;
                }

                ++cnt;
                if (cnt != 2) {
                    ans.append(' ');
                }
                if (vowels.contains(sentence.charAt(i))) {
                    ans.append(sentence.substring(i, j));
                } else {
                    ans.append(sentence.substring(i + 1, j));
                    ans.append(sentence.charAt(i));
                }
                ans.append('m');
                for (int k = 0; k < cnt; ++k) {
                    ans.append('a');
                }

                i = j + 1;
            }

            return ans.toString();
        }
    }


    public void run() {
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(new Solution().toString());
    }

    public static void main(String[] args) throws Exception {
        LC824 an = new LC824();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
